#include "frame_thread_pool.h"

int tcpInit(char *ip, char *port) {
	int sockfd = socket(AF_INET, SOCK_STREAM, 0);

	int flag = 1;
	setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));

	struct sockaddr_in addr;
	addr.sin_family = AF_INET;
	addr.sin_port = htons(atoi(port));
	addr.sin_addr.s_addr = inet_addr(ip);

	bind(sockfd, (struct sockaddr*)&addr, sizeof(addr));

	listen(sockfd, 10);

	return sockfd;
}


int epollAdd(int epfd, int fd) {
	struct epoll_event event;
	event.events = EPOLLIN;
	event.data.fd = fd;

	epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event);

	return 0;
}

int epollDel(int epfd, int fd) {
	epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL);
	return 0;
}
